package com.lft10.sync;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * Function: 		A {@code TestJUC} 测试JUC安全类型的集合.<br/>
 * Reason:   		ADD REASON.<br/>
 * Date:            2021-01-28 9:53<br/>
 * <p>
 * Class Name:      TestJUC<br/>
 * Package Name:    com.lft10.sync<br/>
 * @author Laifengting / E-mail:laifengting@foxmail.com
 * @version 1.0.0
 * @since JDK 8
 */
public class TestJUC {
	public static void main(String[] args) {
		CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<>();
		for (int i = 0; i < 10000; i++) {
			new Thread(() -> {
				list.add(Thread.currentThread().getName());
			}).start();
		}
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(list.size());
	}
}
